#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    vector<vector<int>> mergeArrays(vector<vector<int>>& nums1, vector<vector<int>>& nums2) {
        unordered_map<int, int> hash;
        for (auto& e : nums1)
            hash[e[0]] = e[1];
        for (auto& e : nums2)
            hash[e[0]] += e[1];

        vector<vector<int>> ret;
        for (auto& [a, b] : hash)
        {
            ret.push_back({ a,b });
        }

        sort(ret.begin(), ret.end());

        return ret;
    }
};